package com.been.common.service.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import com.been.common.dao.PublicDAO;
import com.been.common.service.PublicService;

/**
 * 公共service 实现类
 * @author been
 * 2011-10-02
 */
public class PublicServiceImpl implements PublicService {
	
	/**
	 * 公共数据访问接口
	 */
	private PublicDAO publicDAO;
	
	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#save(java.lang.Object)
	 */
	public void save(Object object) {
		this.publicDAO.save(object);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#delete(java.lang.Object)
	 */
	public void delete(Object object) {
		this.publicDAO.delete(object);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#delete(java.lang.Class, java.io.Serializable)
	 */
	public <M> void delete(Class<M> clazz, Serializable id) {
		this.publicDAO.delete(clazz, id);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#update(java.lang.Object)
	 */
	public void update(Object object) {
		this.publicDAO.update(object);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#updateByQuery(java.lang.String, java.lang.Object[])
	 */
	public void updateByQuery(String queryString, Object[] parameters) {
		this.publicDAO.updateByQuery(queryString, parameters);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#find(java.lang.Class, java.io.Serializable)
	 */
	public <M> M find(Class<M> entityClass, Serializable id) {
		return this.publicDAO.find(entityClass, id);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#find(java.lang.Class, java.lang.String)
	 */
	public <M> List<M> find(Class<M> entityClass, String hql) {
		return this.publicDAO.find(entityClass, hql);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#createQuery(java.lang.String)
	 */
	public Query createQuery(String hql) {
		return this.createQuery(hql);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#createSQLQuery(java.lang.String)
	 */
	public Query createSQLQuery(String sql) {
		return this.publicDAO.createSQLQuery(sql);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#getCurSession()
	 */
	public Session getCurSession() {
		return this.publicDAO.getCurSession();
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#deleteAll(java.util.List)
	 */
	public <M> void deleteAll(List<M> objList) {
		this.deleteAll(objList);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#load(java.lang.Class, java.io.Serializable)
	 */
	public <M> M load(Class<M> entityClass, Serializable id) {
		return this.publicDAO.load(entityClass, id);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#get(java.lang.Class, java.io.Serializable)
	 */
	public <M> M get(Class<M> entityClass, Serializable id) {
		return this.publicDAO.get(entityClass, id);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#findAll(java.lang.Class)
	 */
	public <M> List<M> findAll(Class<M> entityClass) {
		return this.publicDAO.findAll(entityClass);
	}

	/* (non-Javadoc)
	 * @see com.been.common.service.PublicService#deleteAll(java.lang.Class)
	 */
	public <M> Integer deleteAll(Class<M> entityClass) {
		return this.publicDAO.deleteAll(entityClass);
	}
	
	public PublicDAO getPublicDAO() {
		return publicDAO;
	}

	public void setPublicDAO(PublicDAO publicDAO) {
		this.publicDAO = publicDAO;
	}

}
